package com.ittsang.controller;

import com.ittsang.dto.CommentDTO;
import com.ittsang.dto.PageDTO;
import com.ittsang.dto.R;
import com.ittsang.service.CommentService;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;

@RestController
@RequestMapping("/comment")
public class CommentController {

    @Resource
    private CommentService commentService;

    /**
     *  根据文章id获取文章评论
     * @param pageDTO
     * @return
     */
    @PostMapping("/getCommentByArticle")
    public R getCommentByArticle(@RequestBody PageDTO pageDTO) {
        return commentService.getCommentByArticle(pageDTO);
    }

    /**
     *  用户添加文章评论
     * @param commentDTO
     * @return
     */
    @PostMapping("/insertComment")
    public R insertComment(@RequestBody CommentDTO commentDTO) {
        return commentService.insertComment(commentDTO);
    }

    @GetMapping("/deletedComment")
    public R deletedComment(@RequestParam("commentId") Integer commentId) {
        return commentService.deletedComment(commentId);
    }

    /**
     *  获取用户全部评论
     * @param pageDTO
     * @return
     */
    @PostMapping("/getUserAllComment")
    public R getUserAllComment(@RequestBody PageDTO pageDTO) {
        return commentService.getUserAllComment(pageDTO);
    }


}
